package com.devilvan.betrice.aiqicha.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.devilvan.betrice.aiqicha.dto.AiqichaShareholdersDto;
import com.devilvan.betrice.aiqicha.po.AiqichaShareholdersPo;
import com.devilvan.betrice.aiqicha.service.AiqichaShareholdersService;
import com.devilvan.betrice.aiqicha.mapper.AiqichaShareholdersMapper;
import com.devilvan.betrice.aiqicha.repository.AiqichaShareholdersRepository;
import com.devilvan.betrice.util.UCopy;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
* @author Evad.Wu
* @Description 爱企查-股东信息 业务逻辑类
* @date 2022-09-24
*/
@Service
public class AiqichaShareholdersServiceImpl extends ServiceImpl<AiqichaShareholdersMapper, AiqichaShareholdersPo> implements AiqichaShareholdersService {
    @Resource(name = "aiqichaShareholdersRepository")
    private AiqichaShareholdersRepository aiqichaShareholdersRepository;

    @Override
    public AiqichaShareholdersPo saveUpdate(AiqichaShareholdersDto aiqichaShareholdersDto) {
        AiqichaShareholdersPo aiqichaShareholdersPo = new AiqichaShareholdersPo();
        UCopy.fullCopy(aiqichaShareholdersDto, aiqichaShareholdersPo);
        return aiqichaShareholdersRepository.saveAndFlush(aiqichaShareholdersPo);
    }

    @Override
    public List<AiqichaShareholdersPo> saveUpdateBatch(List<AiqichaShareholdersDto> list) {
        List<AiqichaShareholdersPo> aiqichaShareholdersPoList = UCopy.fullCopyCollections(list, AiqichaShareholdersPo.class);
        return aiqichaShareholdersRepository.saveAllAndFlush(aiqichaShareholdersPoList);
    }
}
